﻿using System;
namespace Producers.Arireg.Xtee.Riik.Ee.Producer.Arireg {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="mtasidevahendid_sidevahend", Namespace="http://producers.arireg.xtee.riik.ee/producer/arireg", Target=typeof(MtasidevahendidSidevahend))]
    public class MtasidevahendidSidevahendSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IMtasidevahendidSidevahend clazz;
        
        public MtasidevahendidSidevahendSerializer(IMtasidevahendidSidevahend clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            Writer.WriteStartElement("side_id");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.SideId))).ToString());
            Writer.WriteEndElement();
            Writer.WriteStartElement("ark");
            if (clazz.Ark!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "integer");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdInteger(((decimal)(clazz.Ark))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("sliik");
            if (clazz.Sliik!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Sliik))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("numb");
            if (clazz.Numb!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Numb))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("keht_kaot_kpv");
            if (clazz.KehtKaotKpv!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.KehtKaotKpv))).ToString());
            }
            else {
                Writer.WriteAttributeString("xsi", "nil", null, "1");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("muutus");
            if (clazz.Muutus!=null) {
                Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "string");
                Writer.WriteString(new global::Xtee.Core.Schema.XsdString(((string)(clazz.Muutus))).ToString());
            }
            else {
                throw new global::Xtee.Core.Exceptions.NillableNotAllowedException("Nullable is not allowed for element : Muutus");
            }
            Writer.WriteEndElement();
            Writer.WriteStartElement("mkuup");
            Writer.WriteTypeAttribute("http://www.w3.org/2001/XMLSchema", "date");
            Writer.WriteString(new global::Xtee.Core.Schema.XsdDate(((System.DateTime)(clazz.Mkuup))).ToString());
            Writer.WriteEndElement();
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="side_id") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtasidevahendid_sidevahend>side_id");
                }
                clazz.SideId = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("side_id")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>side_id", Reader.LocalName);
            }
            if (Reader.LocalName=="ark") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Ark = new global::Xtee.Core.Schema.XsdInteger(Reader.ReadElementString("ark")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>ark", Reader.LocalName);
            }
            if (Reader.LocalName=="sliik") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Sliik = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("sliik")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>sliik", Reader.LocalName);
            }
            if (Reader.LocalName=="numb") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.Numb = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("numb")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>numb", Reader.LocalName);
            }
            if (Reader.LocalName=="keht_kaot_kpv") {
                if ((Reader.IsElementNil() == false)) {
                    clazz.KehtKaotKpv = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("keht_kaot_kpv")).Value;
                }
                else {
                    Reader.Skip();
                }
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>keht_kaot_kpv", Reader.LocalName);
            }
            if (Reader.LocalName=="muutus") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtasidevahendid_sidevahend>muutus");
                }
                clazz.Muutus = new global::Xtee.Core.Schema.XsdString(Reader.ReadElementString("muutus")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>muutus", Reader.LocalName);
            }
            if (Reader.LocalName=="mkuup") {
                if (Reader.IsElementNil()) {
                    throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>mtasidevahendid_sidevahend>mkuup");
                }
                clazz.Mkuup = new global::Xtee.Core.Schema.XsdDate(Reader.ReadElementString("mkuup")).Value;
            }
            else {
                throw new global::Xtee.Core.Exceptions.UnExpectedElementException(">>mtasidevahendid_sidevahend>mkuup", Reader.LocalName);
            }
        }
    }
}
